home *** CD-ROM | disk | FTP | other *** search
- ;void write_portion_b(strg,start,num_ch,col,row,color);
- ; unsigned char *strg,start,num_ch,col,row,color;
-
- EXTRN _memory_model:byte
- EXTRN _error_code:byte
- EXTRN _video_page:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _write_portion_b
- _write_portion_b proc near
- push bp ;
- mov bp,sp ;set stack frame
- push di ;
- push si ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: push ds ;
- mov bh,_video_page ;set video page
- cmp _memory_model,2 ;data near or far?
- jb L0 ;jump if near
- lds si,dword ptr[bp+4] ;DS:SI pts to Strg
- inc bp ;add 2 to BP since dword ptr
- inc bp ;
- jmp short L00 ;
- L0: mov si,[bp+4] ;near case
- L00: mov bl,[bp+14] ;attribute in BL
- mov dh,[bp+12] ;row in DH
- dec dh ;count from 0
- mov dl,[bp+10] ;col in DL
- dec dl ;count from 0
- sub ax,ax ;clear AX
- cld ;direction forward
- push si ;must find string length
- sub ax,ax ;count in AX
- L000: inc si ;forward strg ptr
- inc ax ;inc counter
- cmp byte ptr[si],0 ;end of string?
- jne L000 ;loop if not
- pop si ;SI back to start of string
- mov byte ptr[bp+14],1 ;errorcode 1 = Strg null
- or ax,ax ;check for null
- jz L4 ;quit if null
- mov di,ax ;use DI as len counter
- inc byte ptr[bp+14] ;2 = start out of range
- mov al,[bp+6] ;get Start
- inc al ;count from 1
- cmp ax,di ;in range?
- ja L4 ;quit if so
- add si,ax ;forward string ptr to Start
- dec si ;
- inc byte ptr[bp+14] ;3 = NumCh out of range
- cmp byte ptr[bp+8],0 ;null?
- je L4 ;
- add al,[bp+8] ;add NumCh to Start
- dec al ;adjust
- cmp ax,di ;longer than string?
- jna L1 ;move along if not
- mov al,[bp+6] ;else grab Start
- sub di,ax ;subtract from string length
- inc di ;adjust
- jmp short L2 ;
- L1: mov byte ptr[bp+14],0 ;0 = no error
- mov al,[bp+8] ;NumCh
- mov di,ax ;set as counter
- L2: mov cx,1 ;chars to write each time
- mov ah,2 ;function to set cursor
- int 10h ;set the cursor
- mov ah,9 ;function to write char
- lodsb ;get a char
- int 10h ;write it
- inc dl ;forward column ptr
- cmp dl,80 ;out or bounds?
- jne L3 ;jump ahead if not
- mov dl,0 ;back to left
- cmp dh,24 ;bottom row?
- je L3 ;jump if so
- inc dh ;else forward row
- L3: dec di ;check len counter
- jnz L2 ;loop till finished
- mov ah,2 ;function to set cursor
- int 10h ;set final curs position
- L4: pop ds ;restore DS
- mov al,[bp+14] ;fetch _error_code
- mov _error_code,al ;set it
- pop si ;
- pop di ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _write_portion_b endp
- _TEXT ENDS
- END